/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package regulatoryInteractionsStats.yeast;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import utils.FileUtils;

/**
 *
 * @author jamie
 */
public class YeastGeneLibrary {

    private HashMap<String, YeastGene> genes_symbol = new HashMap<String, YeastGene>();
    private HashMap<String, YeastGene> genes_accession = new HashMap<String, YeastGene>();
    private HashMap<String, YeastGene> genes_sgd = new HashMap<String, YeastGene>();


    private File geneFile = new File("/Users/jamie/Dropbox/monkeys/yeast/allGenes.txt");

    public YeastGeneLibrary() {
        populate();
    }

    private void populate() {
        BufferedReader reader = FileUtils.getBufferedReader(geneFile);
        String line;
        try {
            while ((line = reader.readLine()) != null) {
                String[] split = line.split("\t");
                YeastGene yg = new YeastGene();
                yg.setAccession(split[0]);
                yg.setSgdId(split[1]);
                yg.setSymbol(split[2]);
                genes_symbol.put(yg.getSymbol(), yg);
                genes_accession.put(yg.getAccession(), yg);
                genes_sgd.put(yg.getSgdId(), yg);
            }
            reader.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public YeastGene getGeneByAccession(String s){
        return genes_accession.get(s);
    }

    public YeastGene getGeneBySymbol(String s){
        return genes_symbol.get(s);
    }

    public YeastGene getGeneBySgdId(String s){
        return genes_sgd.get(s);
    }

    public void printStats() {
        System.out.println(genes_symbol.keySet().size()+", "+genes_accession.keySet().size()+", "+genes_sgd.keySet().size()+"");
    }

    public Set<String> getAllGenes() {
        return genes_symbol.keySet();
    }
    
    



}
